package com.ruoyi.datam.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.base.datam.CmDeviceB;
import com.ruoyi.datam.service.ICmDeviceBService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 监测设备信息记录Controller
 *
 * @author hwd
 * @date 2023-02-21
 */
@RestController
@RequestMapping("/CmDeviceB")
public class CmDeviceBController extends BaseController
{
    @Autowired
    private ICmDeviceBService cmDeviceBService;

    /**
     * 查询监测设备信息记录列表
     */
    @RequiresPermissions("datam:CmDeviceB:list")
    @GetMapping("/list")
    public TableDataInfo list(CmDeviceB cmDeviceB)
    {
        startPage();
        List<CmDeviceB> list = cmDeviceBService.selectCmDeviceBList(cmDeviceB);
        return getDataTable(list);
    }

    /**
     * 查询监测设备信息记录列表
     */
    @RequiresPermissions("datam:CmDeviceB:list")
    @GetMapping("/allList")
    public TableDataInfo allList(CmDeviceB cmDeviceB)
    {
        List<CmDeviceB> list = cmDeviceBService.selectCmDeviceBList(cmDeviceB);
        return getDataTable(list);
    }
    /**
     * 根据测站类型查询设备信息记录列表
     */
    @RequiresPermissions("datam:CmDeviceB:list")
    @GetMapping("/deviceListByType")
    public TableDataInfo deviceListByType(String[] statTypes)
    {
        List<CmDeviceB> list = cmDeviceBService.selectCmDeviceBListByType(statTypes);
        return getDataTable(list);
    }
    /**
     * 导出监测设备信息记录列表
     */
    @RequiresPermissions("datam:CmDeviceB:export")
    @Log(title = "监测设备信息记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmDeviceB cmDeviceB)
    {
        List<CmDeviceB> list = cmDeviceBService.selectCmDeviceBList(cmDeviceB);
        ExcelUtil<CmDeviceB> util = new ExcelUtil<CmDeviceB>(CmDeviceB.class);
        util.exportExcel(response, list, "监测设备信息记录数据");
    }

    /**
     * 获取监测设备信息记录详细信息
     */
    @RequiresPermissions("datam:CmDeviceB:query")
    @GetMapping(value = "/{devCd}")
    public AjaxResult getInfo(@PathVariable("devCd") String devCd)
    {
        return success(cmDeviceBService.selectCmDeviceBByDevCd(devCd));
    }

    /**
     * 新增监测设备信息记录
     */
    @RequiresPermissions("datam:CmDeviceB:add")
    @Log(title = "监测设备信息记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmDeviceB cmDeviceB)
    {
        return toAjax(cmDeviceBService.insertCmDeviceB(cmDeviceB));
    }

    /**
     * 修改监测设备信息记录
     */
    @RequiresPermissions("datam:CmDeviceB:edit")
    @Log(title = "监测设备信息记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmDeviceB cmDeviceB)
    {
        return toAjax(cmDeviceBService.updateCmDeviceB(cmDeviceB));
    }

    /**
     * 删除监测设备信息记录
     */
    @RequiresPermissions("datam:CmDeviceB:remove")
    @Log(title = "监测设备信息记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{devCds}")
    public AjaxResult remove(@PathVariable String[] devCds)
    {
        return toAjax(cmDeviceBService.deleteCmDeviceBByDevCds(devCds));
    }
}
